package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import usuario.ControladorUsuario;
import usuario.Usuario;

/**
 * Servlet implementation class ServletPesquisarUsuario
 */
public class ServletPesquisarUsuario extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
    public ServletPesquisarUsuario() {
        super();
        
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	    Usuario usuario = new Usuario();
		
		String email = (request.getParameter("login"));
		//String senha = (request.getParameter("senha"));
		String mensagem="";
		
		ControladorUsuario control = new ControladorUsuario();
		
		usuario = control.pesquisarUsuario(email);
		
		try{
			usuario = control.pesquisarUsuario(email);
			
	
		response.sendRedirect("RetornoUsuario.jsp?" + "nome=" + usuario.getNome() + "&cpf=" + usuario.getCpf());
		mensagem = "certooo";
		System.out.println(mensagem);
		}catch(Exception e){
			
			mensagem ="Errooo!";
			System.out.println(mensagem);
			
			
		}

		
		
	}

}
